-- CALC_CAVE_19_TARGET_CLASS

-- 计算水元素洞窟的中心格子类型
return function()
    local elem_mine = { ["class"] = 129, ["ratio"] = 100 }; -- 元素矿脉
    local wreckage  = { ["class"] = 90,  ["ratio"] = 15 };  -- 奇怪的残骸
    local wreckage2 = { ["class"] = 91,  ["ratio"] = 15 };  -- 奇怪的残骸B

    local arr = { elem_mine, wreckage, wreckage2};

    -- 残骸只出现一次
    if DungeonInstanceM.getInstanceStat(wreckage["class"]) > 0 then
        wreckage["ratio"] = 0;
    end
    if DungeonInstanceM.getInstanceStat(wreckage2["class"]) > 0 then
        wreckage2["ratio"] = 0;
    end

    -- 迷宫小关不出现
    local dungeonId = DungeonM.getDungeonId();
    if type(dungeonId) == "number" and dungeonId > 0 and
        DungeonAreaM.query(dungeonId, "type") == "child" then
        wreckage["ratio"] = 0;
        wreckage2["ratio"] = 0;
    end

    -- 先过滤一遍
    DungeonInstanceM.filterInstanceGrids(arr);

    local seed = DungeonM.getRandSeed("CALC_CAVE_19_TARGET_CLASS");
    local info = fetchElemBySeed(arr, seed);

    return info["class"];
end
